package com.viknix.springboot.demo.controller;

import com.viknix.springboot.demo.config.Config;
import com.viknix.springboot.demo.service.ConditionalService;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Conditional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: Dongqi
 * @Date: 2021/11/20 13:25
 * @Version 1.0
 * @Description:
 */
@AllArgsConstructor
@RequestMapping("/conditional")
@RestController
public class ConditionalController {

    private ConditionalService conditionalService;

    /**
     * 测试 {@link Conditional} 注解
     *
     * @return 生效的配置
     */
    @GetMapping
    public String testConditional() {
        Map<String, Config> configMap = conditionalService.testConditional();
        return configMap.toString();
    }
}
